import UserDaoImpl from "../dao/UserDaoImpl";
import type { UserInfo } from "../entity/UserInfo";

export default class UserService {
  userInfoDaoImpl: UserDaoImpl = new UserDaoImpl();
  static userServiceImpl: UserService;

  static getInstance() {
    if (!this.userServiceImpl) {
      this.userServiceImpl = new UserService();
    }
    return this.userServiceImpl;
  }

  constructor() {
    console.log("UserService类");
  }

  login(username: string, pwd: string, role: string): UserInfo | null {
    const user = this.userInfoDaoImpl.findUsrByUsm(username, pwd);
    return user || null;
  }

  register() {
    console.log("我是注册");
  }
}
